home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tools / mg / src.lzh / amiga / sysinit.c < prev    next >
C/C++ Source or Header  |  1990-05-23  |  2KB  |  84 lines

  1. /*
  2.  * Name:    MG 2a
  3.  *
  4.  *         Very early-on system-specific initialization for whatever's
  5.  *        necessary.
  6.  * Last edit:    05-May-88, Stephen Walton, swalton@solar.stanford.edu
  7.  * Created:    Stephen Walton, 3-Dec-87.
  8.  *    
  9.  */
  10. #include "no_dir.h"
  11. #include "use_arp.h"
  12.  
  13. #include <libraries/dosextens.h>
  14. #include <exec/types.h>
  15. #include <functions.h>
  16. #include "def.h"
  17. #include "no_dir.h"
  18. #include "use_arp.h"
  19. #include "rexx.h"
  20.  
  21. #undef    FALSE
  22. #undef    TRUE
  23. #define    TRUE    1
  24. #define    FALSE    0
  25.  
  26. #ifdef USE_ARP
  27. struct Library    *ArpBase;
  28. extern struct    Library *OpenLibrary();
  29. #endif
  30.  
  31. #ifndef    NO_DIR
  32. extern struct    Task *FindTask();
  33. static BPTR    StartLock;
  34. char        MyDirName[MAXPATH];
  35. extern BPTR    DupLock(), CurrentDir();
  36. #endif /* NO_DIR */
  37.  
  38. VOID
  39. sysinit()
  40. {
  41. #ifndef    NO_DIR
  42.     long len;
  43.     BPTR MyDirLock;
  44. #endif
  45.  
  46. #ifdef USE_ARP
  47.     if (!(ArpBase = OpenLibrary("arp.library", 0L)))
  48.         panic("Compiled with USE_ARP, but arp.library not found");
  49. #endif
  50. #ifdef    REXX
  51.     openrexx() ;
  52. #endif
  53. #ifndef NO_DIR
  54.     /*
  55.      * The following attempt to be clever assigns the external StartLock
  56.      * to the lock on the current directory, then switches our CurrentDir
  57.      * to a duplicate of that lock so we can restore the original lock
  58.      * on exit.
  59.      */
  60.  
  61.     StartLock = ((struct Process *)FindTask(0L))->pr_CurrentDir;
  62.     (void) CurrentDir(MyDirLock = DupLock(StartLock));
  63.     len = PathName(MyDirLock, MyDirName, MAXPATH);
  64. #endif /* NO_DIR */
  65. }
  66.  
  67. /*
  68.  * System dependent cleanup for the Amiga.
  69.  */
  70. VOID
  71. syscleanup()
  72. {
  73. #ifdef    REXX
  74.     closerexx() ;
  75. #endif
  76. #ifndef    NO_DIR
  77.     UnLock(CurrentDir(StartLock));    /* restore startup directory    */
  78. #endif
  79. #ifdef USE_ARP
  80.     if (ArpBase)
  81.         CloseLibrary(ArpBase);
  82. #endif
  83. }
  84.